﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MaintainSchools
{
    public partial class CoordinatorInfo : Form
    {
        public static User user;
        public CoordinatorInfo(int id)
        {
            InitializeComponent();
            user = Globals.users[id];
            FirstNametxt.Text = user.userFirstName;
            LastNametxt.Text = user.userLastName;
            Passwordtxt.Text = user.userPassword;
            Emailtxt.Text = user.userName;
            Phonetxt.Text = user.userPhone;
            Addrtxt.Text = user.userAddress;
            Citytxt.Text = user.userCity;
            Statetxt.Text = user.userState;
            Ziptxt.Text = user.userZip.ToString();
        }

        private void Savebtn_Click(object sender, EventArgs e)
        {
            if (Emailtxt.Text == "")
            {
                MessageBox.Show("The email of the school coordinator cannot be blank!", "Required Data is missing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                user.userFirstName = FirstNametxt.Text;
                user.userLastName = LastNametxt.Text;
                user.userPassword = Passwordtxt.Text;
                user.userName = Emailtxt.Text;
                user.userPhone = Phonetxt.Text;
                user.userAddress = Addrtxt.Text;
                user.userCity = Citytxt.Text;
                user.userState = Statetxt.Text;
                user.userZip = Convert.ToInt32(Ziptxt.Text);
                Globals.users[user.userID] = user;
                this.Close();
            }
        }

    }
}
